package com.groovy.domain

/**
 * Switch case的使用
 */
class SwitchCaseTest {

    static void main(String[] args) {
        def any = 1.23
        println(switchCase(any))
    }

    /**
     * 定义一个方法
     * @param any
     * @return
     */
    static String switchCase(def any){
        def result = ""
        switch (any) {
            case 'test1':
                result = "test1"
                break
            case [1, 2, 3, "list"]:
                result = "列表"
                break
            case [1..10]:
                result = "范围"
                break
            case Integer:
                result = "Integer"
                break
            case BigDecimal:
                result = "BigDecimal"
                break
            default: result = "default"
        }
        return result
    }
}
